﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MemberPwdEdit.aspx.cs" Inherits="WebSystem.Member.MemberPwdEdit"
    Theme="normal" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>密码修改</title>
    <link href="../css/StyleforBase.css" type="text/css" rel="stylesheet" />
    <link href="../css/font.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
      
function changeUserPwdoldPrompt(cntforpwdold){
	document.getElementById( "divMessageforpwdold" ).style.display="";
	//document.getElementById( "divRecommandName" ).style.display="none";
	document.getElementById( "failinfoforpwdold" ).innerHTML = cntforpwdold;
}



function chkpwdold(obj)
{
     var told=obj.value;
    document.getElementById( "errspan1forpwdold" ).className = "";
	
	changeUserPwdoldPrompt("&nbsp;");
	if( told == "" || told == null ){
	document.getElementById("pwdBoxold").style.borderColor='red';
		changeUserPwdoldPrompt( "请输入旧密码");
		document.getElementById("errspan1forpwdold").className='error';
		return false;
	}
	
	return true;
}


function changeUserPwdPrompt(cntforpwd){
	document.getElementById( "divMessageforpwd" ).style.display="";
	//document.getElementById( "divRecommandName" ).style.display="none";
	document.getElementById( "failinfoforpwd" ).innerHTML = cntforpwd;
}


//密码检测
function chkpwd(obj){

var Bobj=document.getElementById("chkResult");

    Bobj.innerHTML="&nbsp;";
    var t=obj.value;
    document.getElementById( "errspan1forpwd" ).className = "";
	
	changeUserPwdPrompt("&nbsp;");
	if( t == "" || t == null ){
	document.getElementById("pwdBox").style.borderColor='red';
		changeUserPwdPrompt( "请输入新密码");
		document.getElementById("errspan1forpwd").className='error';
		return false;
	}
	
	var id=getResult(t);
	
	
	if(id==0)
	{
	    document.getElementById("pwdBox").style.borderColor='red';
	    
		document.getElementById("errspan1forpwd").className='error';
	    changeUserPwdPrompt(document.getElementById("errspan1forpwd").innerHTML);
		return false;
	}
	else
	{
	
	    //定义对应的消息提示
	    var msg=new Array(4);
	    msg[0]="密码过短。";
	    msg[1]="密码强度差。";
	    msg[2]="密码强度良好。";
	    msg[3]="密码强度高。";
    	
	    var sty=new Array(4);
	    sty[0]=-45;
	    sty[1]=-30;
	    sty[2]=-15;
	    sty[3]=0;
    	
	    var col=new Array(4);
	    col[0]="red";
	    col[1]="gray";
	    col[2]="#ff6600";
	    col[3]="Green";
    	
	    //设置显示效果
	    //var bImg="../sysImages/user/qd.gif";//一张显示用的图片
	    var sWidth=300;
	    var sHeight=15;
    	

	    Bobj.style.fontSize="12px";
	    Bobj.style.color=col[id];
	    Bobj.style.width=sWidth + "px";
	    Bobj.style.height=sHeight + "px";
	    Bobj.style.lineHeight=sHeight + "px";
	    //Bobj.style.background="url(" + bImg + ") no-repeat left " + sty[id] + "px";
	    Bobj.style.textIndent="20px";
	   Bobj.innerHTML="检测提示：" + msg[id];       
	}
	
	
//	if(document.getElementById( "pwdsBox" ).value!=null||document.getElementById( "pwdsBox" ).value!="")
//	{
//	    chkpwds(document.getElementById( "pwdsBox" ).value);
//	}
	
	
	return true;
}

//定义检测函数,返回0/1/2/3分别代表无效/差/一般/强
function getResult(s){
 
	if(s.length < 6&& s.length>0){
		return 0;
	}
	var ls = 0;
	if (s.match(/[a-z]/ig)){
		ls++;
	}
	if (s.match(/[0-9]/ig)){
		ls++;
	}
 	if (s.match(/(.[^a-z0-9])/ig)){
		ls++;
	}
	if (s.length < 6 && ls > 0){
		ls--;
	}
	return ls
}


//确认密码检测
function chkpwds(obj)
{
     var strpwds=obj.value;
     var strpwd=document.getElementById( "pwdBox" ).value;
     
     document.getElementById( "errspan1forpwds" ).className = "";
	
	changeUserPwdsPrompt("&nbsp;");
	if( strpwds == "" || strpwds == null ){
	document.getElementById("pwdsBox").style.borderColor='red';
		changeUserPwdsPrompt( "请输入确认密码");
		document.getElementById("errspan1forpwds").className='error';
		return false;
	}
	
	if(strpwds!=strpwd)
	{
	    document.getElementById("pwdsBox").style.borderColor='red';
		changeUserPwdsPrompt(document.getElementById("errspan1forpwds").innerHTML);
		document.getElementById("errspan1forpwds").className='error';
		return false;
	}
	return true;
	
	
	
     
}
function changeUserPwdsPrompt(strforpwds)
{
    document.getElementById( "divMessageforpwds" ).style.display="";
	
	document.getElementById( "failinfoforpwds" ).innerHTML = strforpwds;
}

function fLen(Obj){
  var nCNLenth = 0;
  var nLenth = Obj.length;
  for (var i=0; i<nLenth; i++){
    if(Obj.charCodeAt(i)>255){
      nCNLenth += 2; 
    }else{
      nCNLenth++;
    }
  }
  return nCNLenth;
}






//终验
function zongcheck()
{
    
    var zongcheckforall=true;
   


    zongcheckforall=chkpwdold(document.getElementById("pwdBoxold"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }
    
    
    zongcheckforall=chkpwd(document.getElementById("pwdBox"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }
    
    zongcheckforall=chkpwds(document.getElementById("pwdsBox"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }

}



    </script>

</head>
<body style="margin: 0px; background-color: #ffffff;">
    <form id="form1" runat="server">
        <div class="normalnav">
            <div class="normalcontent">
                个性设置>>>密码修改</div>
        </div>
        <div class="normalmenu">
            <div class="normalmenucontent1">
                <table>
                    <tr>
                        <td>
                            <asp:ImageButton ID="ibtnedit" runat="server" ImageUrl="../Images/Basic/edit.gif"
                                ToolTip="修改" OnClientClick="javascript:return zongcheck();" OnClick="ibtnedit_Click" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </td>
                        <td>
                            <asp:ImageButton ID="ibtnback" runat="server" ImageUrl="../Images/Basic/fanhui.gif"
                                ToolTip="返回" OnClick="ibtnback_Click" Visible="false" /></td>
                        <td>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="normalgrid">
            <table cellpadding="0" cellspacing="0" border="0" width="800px">
                <tr>
                    <td class="leftforregister">
                        旧密码：
                    </td>
                    <td class="centerforregister" style="width: 23%">
                        <asp:TextBox ID="pwdBoxold" runat="server" Width="184px" MaxLength="18" TextMode="Password"
                            onfocus="this.style.borderColor='#000000'" onblur=" this.style.borderColor='#A3BFA8';chkpwdold(this);" BorderColor="#1e83b6"
                            BorderStyle="Solid" BorderWidth="1" Height="20px"></asp:TextBox>
                    </td>
                    <td class="rightforregister">
                        <span id="errspan1forpwdold">请输入旧密码</span><br />
                    </td>
                </tr>
                <!--旧密码检测结果-->
                <tr height="20px">
                    <td class="leftforregister">
                    </td>
                    <td class="jyjgforregister" colspan="2">
                        <div id="divMessageforpwdold" style="display: none">
                            <span id="failinfoforpwdold"></span>
                        </div>
                        <span id="chkResultold"></span>
                    </td>
                </tr>
                <tr>
                    <td class="leftforregister">
                        新密码：
                    </td>
                    <td class="centerforregister" style="width: 23%">
                        <asp:TextBox ID="pwdBox" runat="server" Width="184px" MaxLength="18" TextMode="Password"
                            onfocus="this.style.borderColor='#000000'" onblur=" this.style.borderColor='#A3BFA8';chkpwd(this);" BorderColor="#1e83b6"
                            BorderStyle="Solid" BorderWidth="1" Height="20px"></asp:TextBox>
                    </td>
                    <td class="rightforregister">
                        <span id="errspan1forpwd">新密码长度6～18位，由英文字母a～z (区分大小写)，数字0～9，特殊字符组成。</span><br />
                    </td>
                </tr>
                <!--密码检测结果-->
                <tr height="25px">
                    <td class="leftforregister">
                    </td>
                    <td class="jyjgforregister" colspan="2">
                        <div id="divMessageforpwd" style="display: none">
                            <span id="failinfoforpwd"></span>
                        </div>
                        <span id="chkResult"></span>
                    </td>
                </tr>
                <!--确认密码-->
                <tr>
                    <td class="leftforregister">
                        确认新密码：
                    </td>
                    <td class="centerforregister" style="width: 23%">
                        <asp:TextBox ID="pwdsBox" runat="server" Width="184px" TextMode="Password" onfocus="this.style.borderColor='#000000'"
                            onblur=" this.style.borderColor='#A3BFA8';chkpwds(this);" BorderColor="#1e83b6"
                            BorderStyle="Solid" BorderWidth="1" Height="20px"></asp:TextBox>
                    </td>
                    <td class="rightforregister">
                        <span id="errspan1forpwds">确认新密码应与新密码一致。</span><br />
                    </td>
                </tr>
                <!--密码检测结果-->
                <tr height="20px">
                    <td class="leftforregister">
                    </td>
                    <td class="jyjgforregister" colspan="2">
                        <div id="divMessageforpwds" style="display: none">
                            <span id="failinfoforpwds"></span>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
